package com.ztf0337.mycurriculumdesign.entity;

import androidx.room.ColumnInfo;
import androidx.room.Entity;
import androidx.room.PrimaryKey;

import java.util.Objects;

@Entity(tableName = "order_table")
public class Order {
    @PrimaryKey(autoGenerate = true)
    private Long id;
    @ColumnInfo(name = "user_id")
    private Long userId;
    @ColumnInfo(name = "park_lot_id")
    private Long parkLotId;
    @ColumnInfo(name = "parking_space_id")
    private Long parkingSpaceId;
    @ColumnInfo(name = "parking_space_number")
    private String parkingSpaceNumber;
    @ColumnInfo(name = "park_lot_name")
    private String parkLotName;
    @ColumnInfo(name = "licence_plate")
    private String licencePlate;
    @ColumnInfo(name = "location")
    private String location;
    @ColumnInfo(name = "total_price")
    private Double totalPrice;
    @ColumnInfo(name = "start_time")
    private Long startTime;
    @ColumnInfo(name = "end_time")
    private Long endTime;
    @ColumnInfo(name = "parkType")
    private String parkType;
    @ColumnInfo(name = "order_number")
    private String orderNumber;
    @ColumnInfo(name = "transaction_status")
    private Boolean transactionStatus;
    @ColumnInfo(name = "total_time")
    private Double totalTime;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Long getUserId() {
        return userId;
    }

    public void setUserId(Long userId) {
        this.userId = userId;
    }

    public Long getParkLotId() {
        return parkLotId;
    }

    public void setParkLotId(Long parkLotId) {
        this.parkLotId = parkLotId;
    }

    public Long getParkingSpaceId() {
        return parkingSpaceId;
    }

    public void setParkingSpaceId(Long parkingSpaceId) {
        this.parkingSpaceId = parkingSpaceId;
    }

    public String getParkingSpaceNumber() {
        return parkingSpaceNumber;
    }

    public void setParkingSpaceNumber(String parkingSpaceNumber) {
        this.parkingSpaceNumber = parkingSpaceNumber;
    }

    public String getParkLotName() {
        return parkLotName;
    }

    public void setParkLotName(String parkLotName) {
        this.parkLotName = parkLotName;
    }

    public String getLicencePlate() {
        return licencePlate;
    }

    public void setLicencePlate(String licencePlate) {
        this.licencePlate = licencePlate;
    }

    public String getLocation() {
        return location;
    }

    public void setLocation(String location) {
        this.location = location;
    }

    public Double getTotalPrice() {
        return totalPrice;
    }

    public void setTotalPrice(Double totalPrice) {
        this.totalPrice = totalPrice;
    }

    public Long getStartTime() {
        return startTime;
    }

    public void setStartTime(Long startTime) {
        this.startTime = startTime;
    }

    public Long getEndTime() {
        return endTime;
    }

    public void setEndTime(Long endTime) {
        this.endTime = endTime;
    }

    public String getParkType() {
        return parkType;
    }

    public void setParkType(String parkType) {
        this.parkType = parkType;
    }

    public String getOrderNumber() {

        return orderNumber;
    }

    public void setOrderNumber(String orderNumber) {
        this.orderNumber = orderNumber;
    }

    public Boolean getTransactionStatus() {
        return transactionStatus;
    }

    public void setTransactionStatus(Boolean transactionStatus) {
        this.transactionStatus = transactionStatus;
    }

    public Double getTotalTime() {
        return totalTime;
    }

    public void setTotalTime(Double totalTime) {
        this.totalTime = totalTime;
    }

    public void initializeByRent(RentedParkingSpace rentedParkingSpace) {
        this.userId = rentedParkingSpace.getUserId();
        this.parkingSpaceId = rentedParkingSpace.getParkingSpaceId();
        this.parkLotId = rentedParkingSpace.getParkLotId();
        this.location = rentedParkingSpace.getLocation();
        this.startTime = rentedParkingSpace.getStartTime();
        this.licencePlate = rentedParkingSpace.getLicencePlate();
        this.parkingSpaceNumber = rentedParkingSpace.getParkingSpaceNumber();
        this.parkLotName = rentedParkingSpace.getParkLotName();
        this.parkType = rentedParkingSpace.getType();
    }

    public Order() {
    }

    public Order(Long id,
                 Long userId,
                 Long parkLotId,
                 Long parkingSpaceId,
                 String parkingSpaceNumber,
                 String parkLotName,
                 String licencePlate,
                 String location,
                 Double totalPrice,
                 Long startTime,
                 Long endTime,
                 String parkType,
                 String orderNumber,
                 Boolean transactionStatus,
                 Double totalTime) {
        this.id = id;
        this.userId = userId;
        this.parkLotId = parkLotId;
        this.parkingSpaceId = parkingSpaceId;
        this.parkingSpaceNumber = parkingSpaceNumber;
        this.parkLotName = parkLotName;
        this.licencePlate = licencePlate;
        this.location = location;
        this.totalPrice = totalPrice;
        this.startTime = startTime;
        this.endTime = endTime;
        this.parkType = parkType;
        this.orderNumber = orderNumber;
        this.transactionStatus = transactionStatus;
        this.totalTime = totalTime;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Order order = (Order) o;
        return Objects.equals(id, order.id);  // ID 是唯一标识
    }

    @Override
    public int hashCode() {
        return Objects.hash(id);
    }

}
